/* 全局样式 */
body {
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #1a2a6c);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: white;
    overflow: hidden;
    position: relative;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* 游戏容器 */
#game-container {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 900px;
    width: 100%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 5;
}

/* 游戏头部 */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.game-header h1 {
    font-size: 2.2rem;
    margin: 0;
    text-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00;
    letter-spacing: 2px;
    flex: 1;
    min-width: 200px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.header-btn {
    background: linear-gradient(to bottom, #9C27B0, #7B1FA2);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.header-btn:hover {
    background: linear-gradient(to bottom, #AB47BC, #8E24AA);
    transform: translateY(-1px);
}

/* 分数显示 */
#score-display {
    font-size: 1.6rem;
    font-weight: bold;
    color: #ffcc00;
    text-shadow: 0 0 5px rgba(255, 204, 0, 0.5);
    white-space: nowrap;
}

/* 游戏设置区域 */
.game-settings {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

#difficulty-section {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
}

#audio-controls {
    display: flex;
    align-items: center;
}

.setting-btn {
    background: #444;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.setting-btn:hover {
    background: #555;
    transform: translateY(-1px);
}

#difficulty-select {
    background: linear-gradient(to bottom, #f0f0f0, #e0e0e0);
    color: #333;
    padding: 8px 15px;
    border: 2px solid #666;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 0 #111;
}

#difficulty-select option {
    background-color: white;
    color: #333;
}

#difficulty-select:focus {
    outline: none;
    border-color: #4CAF50;
}

/* 成就榜弹窗 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal {
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(156, 39, 176, 0.1);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: #9C27B0;
    text-shadow: 0 0 10px rgba(156, 39, 176, 0.5);
}

.close-btn {
    background: none;
    border: none;
    color: #ccc;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.modal-content {
    padding: 20px 25px;
    max-height: 50vh;
    overflow-y: auto;
    text-align: left;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

.achievement-tip {
    margin: 0;
    text-align: center;
    font-size: 0.9rem;
    color: #ccc;
    font-style: italic;
}

/* 统计信息栏 */
.stats-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    font-size: 0.85rem;
    color: #ccc;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.3);
    flex-wrap: wrap;
}

.stats-bar span {
    white-space: nowrap;
    padding: 2px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.achievement-item {
    padding: 10px;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border-left: 4px solid #9C27B0;
}

.achievement-item.completed {
    border-left: 4px solid #4CAF50;
}

.achievement-name {
    font-weight: bold;
    color: #9C27B0;
    font-size: 1.1rem;
}

.achievement-item.completed .achievement-name {
    color: #4CAF50;
}

.achievement-timestamp {
    font-size: 0.9rem;
    color: #ccc;
    margin-top: 5px;
}

/* 游戏区域 */
#game-area {
    margin: 20px 0;
}

.game-main {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 30px;
    margin-bottom: 20px;
}

/* 游戏画板容器 */
#game-board-container {
    position: relative;
    display: inline-block;
    border: 4px solid #333;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.7);
}

#game-board-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 25px 25px;
    pointer-events: none;
    z-index: -1;
}

/* 游戏画板 */
#game-board {
    display: block;
    background-color: #111;
    border: none;
    width: 500px;
    height: 500px;
}

/* 控制区域 */
#controls-section {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
    min-width: 180px;
}

.control-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

/* 游戏按钮样式 */
.game-btn {
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.5px;
    width: 100%;
    min-width: 140px;
}

.game-btn.primary {
    background: linear-gradient(to bottom, #4CAF50, #2E7D32);
}

.game-btn.primary:hover {
    background: linear-gradient(to bottom, #66BB6A, #388E3C);
    transform: translateY(-2px);
}

.game-btn.secondary {
    background: linear-gradient(to bottom, #FF9800, #F57C00);
}

.game-btn.secondary:hover {
    background: linear-gradient(to bottom, #FFA726, #FB8C00);
    transform: translateY(-2px);
}

.game-btn.tertiary {
    background: linear-gradient(to bottom, #2196F3, #0D47A1);
}

.game-btn.tertiary:hover {
    background: linear-gradient(to bottom, #42A5F5, #1565C0);
    transform: translateY(-2px);
}

.game-btn:active {
    transform: translateY(1px);
}

/* 移动端控制优化 */
.mobile-controls-optimized {
    display: none;
    margin-top: 20px;
}

/* 按键容器 */
.key-row {
    display: flex;
    justify-content: center;
    margin: 8px 0;
}

.key {
    width: 60px;
    height: 60px;
    background: linear-gradient(to bottom, #444, #222);
    border: 2px solid #666;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0 6px;
    box-shadow: 0 4px 0 #111;
    user-select: none;
    transition: all 0.1s ease;
    cursor: pointer;
}

.key.active {
    background: linear-gradient(to bottom, #666, #444);
    transform: translateY(2px);
    box-shadow: 0 2px 0 #111;
}

/* 紧凑的指示说明 */
.instructions-compact {
    padding: 12px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    width: 100%;
}

.instruction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 6px 0;
    font-size: 0.9rem;
    color: #ccc;
}

.key-hint {
    background: rgba(255, 255, 255, 0.15);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.8rem;
    font-weight: bold;
}

/* 消息显示 */
#message-display {
    font-size: 2.2rem;
    font-weight: bold;
    color: #ff3333;
    min-height: 60px;
    margin: 20px 0;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    #game-container {
        padding: 15px;
        margin: 10px;
    }

    .game-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .game-header h1 {
        font-size: 1.8rem;
    }

    #score-display {
        font-size: 1.4rem;
    }

    .game-settings {
        gap: 20px;
    }

    .stats-bar {
        gap: 10px;
        font-size: 0.8rem;
    }

    .game-main {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    #game-board {
        width: 350px;
        height: 350px;
    }

    #game-board-container::before {
        background-size: 17.5px 17.5px;
    }

    #controls-section {
        width: 100%;
        max-width: 350px;
    }

    .mobile-controls-optimized {
        display: block;
        width: 100%;
    }

    .key {
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
        margin: 0 4px;
    }

    .modal {
        margin: 10px;
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    #game-container {
        padding: 12px;
    }

    .game-header h1 {
        font-size: 1.6rem;
    }

    #score-display {
        font-size: 1.2rem;
    }

    .game-settings {
        flex-direction: column;
        gap: 15px;
    }

    .stats-bar {
        flex-direction: column;
        gap: 8px;
        font-size: 0.75rem;
    }

    #game-board {
        width: 300px;
        height: 300px;
    }

    #game-board-container::before {
        background-size: 15px 15px;
    }

    .key {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
        margin: 0 3px;
    }

    .game-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
        min-width: 120px;
    }

    #message-display {
        font-size: 1.6rem;
        min-height: 50px;
    }

    .modal-header,
    .modal-content,
    .modal-footer {
        padding: 15px 20px;
    }

    .instructions-compact {
        padding: 10px;
    }

    .instruction-item {
        font-size: 0.8rem;
    }
}